home *** CD-ROM | disk | FTP | other *** search
- Path: sdcc12.ucsd.edu!golgi!jstrout
- From: Joseph Strout <jstrout@ucsd.edu>
- Newsgroups: comp.lang.c++
- Subject: fast sorted-list implementation for event-based sim?
- Date: Tue, 27 Feb 1996 11:15:17 -0800
- Organization: University of California, San Diego
- Message-ID: <Pine.SGI.3.91.960227110848.17017C-100000@golgi>
- NNTP-Posting-Host: golgi.ucsd.edu
- Mime-Version: 1.0
- Content-Type: TEXT/PLAIN; charset=US-ASCII
- X-Sender: jstrout@golgi
-
- I'm considering writing an event-based simulation package. The needs are
- simple: events go into a collection with an event-time; they may be put
- in in any order (though in general, they will be entered in rough order).
- They need to be taken out in order. Both operations need to be very fast.
-
- I've just examined one implementation of such a thing, that builds a big
- (fixed-size) array of events. To insert an event, it crawls through the
- array to the first unused slot and sticks it there. To find the next
- event, it goes through all events sequentially, and finds the one with
- the earliest event time.
-
- Surely this could be done better? With a dynamically-allocated linked
- list, for example, we could insert freely at the end of the list, and do
- the Find as above. Or will all that new'ing and delete'ing slow me down?
-
- Perhaps it would be better to maintain the list in sorted order in the
- first place (i.e., as each event is inserted). This could be done with a
- b-tree structure, I suppose. (Are there any publicly available
- implementations of such a data structure?)
-
- Any advice would be greatly appreciated. This will be used for
- educational/research freeware, not for commercial purposes.
-
- ,------------------------------------------------------------------.
- | Joseph J. Strout Department of Neuroscience, UCSD |
- | jstrout@ucsd.edu http://www-acs.ucsd.edu/~jstrout/ |
- `------------------------------------------------------------------'
-
-